#!/usr/bin/env bash
echo "deploy pscm"

apphome=$1
app=$2
ips=$3
appuser=$4


OLD_IFS=$IFS
IFS=',' arr=($ips)
IFS=$OLD_IFS
for item in ${arr[@]}; do
  echo "in th loop"
  echo " $appuser@$item:$apphome/$app "
    ssh $appuser@$item "mkdir -p $apphome/$app/ && rm -rf $apphome/$app/*"
    scp -r $CI_PROJECT_DIR/dist/* $appuser@$item:$apphome/$app/
    scp -r $CI_PROJECT_DIR/src/ $appuser@$item:$apphome/$app/src
    scp -r $CI_PROJECT_DIR/library/ $appuser@$item:$apphome/$app/library
done